import { ARR_METHODS } from "./config"
import observeArr from './observeArr'

const originArrMethods = Array.prototype,
  arrMethods = Object.create(originArrMethods)
ARR_METHODS.map(function(m) {
  arrMethods[m] = function() {
    let args = Array.prototype.slice.call(arguments),
      rt = originArrMethods[m].apply(this, args)
    let newArr
    switch (m) {
      case 'push':
        break;
      case 'unshift':
        newArr = args
        break;
      case 'splice':
        newArr = args.splice(2)
        break;
      default:
        break;
    }
    newArr && observeArr(newArr)
    return rt
  }
})

export {
  arrMethods
}

